<?php
session_start();

if(!isset($_SESSION['userid']))//检查 userid 是否已经设置，如果没有设置，提示未登录并跳转首页
{
    echo "<script>alert('您尚未登录！')</script>";
    echo "<script>window.location.href='index.php'</script>";

}
include ('mysqli_connect.php');

//下面四个是向表中添加数据需要的属性值
$userid=$_SESSION['userid'];


$sheetid = $_REQUEST["sheetid"];

$movieid = $_REQUEST["movieid"];

$shitname = $_REQUEST["shitname"];

//这里在之前的页面已经判断过了，只有在没有记录的情况下才能点击按钮跳转到这个页面添加记录，故只需要insert即可。
//$sqlp = "select * from user_mark_table where movie_id='{$movie_id}' and user_id='{$userid}';";
$sqlp = "insert into movie_sheet_table (movie_sheet_id,user_id,movie_id,sheet_name)
                                    values 
                                        ('{$sheetid}','{$userid}','{$movieid}','{$shitname}');";
$resp = mysqli_query($dbc,$sqlp);
//$resultp = mysqli_fetch_array($resp);
if($resp != false)
{

    echo "<script>alert('添加成功！')</script>";
    echo "<script>window.location.href='user_sheet.php'</script>";
}
else
{
    echo "<script>alert('添加失败！')</script>";
    echo "<script>window.location.href='user_querymovie.php'</script>";
}

?>
